﻿using System.Data;
using MiniExcelLibs;

namespace Digitalmes.Infrastructure.IO;

/// <summary>
/// Excel 处理
/// </summary>
public sealed class ExcelManager
{
    public Stream SaveAsStream(DataTable table)
    {
        MemoryStream ms = new();
        ms.SaveAs(table);
        ms.Seek(0, SeekOrigin.Begin);

        return ms;
    }

    public Stream SaveAsStream<T>(IEnumerable<T> list)
    {
        MemoryStream ms = new();
        ms.SaveAs(list);
        ms.Seek(0, SeekOrigin.Begin);

        return ms;
    }
}
